<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$isRealPayOffJumpWager = (int)$_KSysParam[isRealPayOffJumpWager];

$strSQL = "select * from `bet_Lotto` where ID = ".(int)$_data["ID"];
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Lotto Data Error!!";
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}else{
	$objLotto = PMA_mysql_fetch_object($RS);
}


//找出 Lotto 的下注參數，傳回陣列
if(!$arrBP = GetArrayBetParam($_data["ID"], $objLotto -> LType))ErrMsgOutputHTML("Error", "", 1);

$arrBT = array();
$strSQL =  "select ID as BID, Type_Value_".$_intLang." as Type_Value from `bet_BetType` where LType = '".$objLotto -> LType."' order by ID";
if($subRS = @PMA_mysql_query($strSQL, $$_Conn)){
	if(PMA_mysql_num_rows($subRS) > 0){
		while($subRows = PMA_mysql_fetch_object($subRS)){
			$arrBT[$subRows -> BID] = $subRows -> Type_Value;
		}
	}
}

$arrFirstBT = array(1 => 1, 2 => 51, 3 => 1, 4 => 1);
$intFirstBT = $arrFirstBT[$objLotto -> LType];

$fp = @file($strTemplatePath."Params.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{intID}", $objLotto -> ID, $fp);
$strLo = "Lotto_".$_intLang;
$fp = str_replace("{ShowLotto}", $objLotto -> $strLo, $fp);
$fp = str_replace("{SpecialNumberABOddsGap}", $_KSysParam[SpecialNumberABOddsGap], $fp);
$fp = str_replace("{SpecialNumberABOddsGap2}", $_KSysParam[SpecialNumberABOddsGap2], $fp);
$fp = str_replace("{SpecialNumberABOddsGap3}", $_KSysParam[SpecialNumberABOddsGap3], $fp);
$fp = str_replace("{SpecialNumberAOdds2}", $_KSysParam[SpecialNumberAOdds2], $fp);
$fp = str_replace("{SpecialNumberAOdds3}", $_KSysParam[SpecialNumberAOdds3], $fp);
$fp = str_replace("{SpecialNumberBOdds2}", $_KSysParam[SpecialNumberBOdds2], $fp);
$fp = str_replace("{SpecialNumberBOdds3}", $_KSysParam[SpecialNumberBOdds3], $fp);

while(list($k, $v) = each($_strLotto)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

preg_match("/<!-- @ PName Start @ \/\/-->(.+)<!-- @ PName End @ \/\/-->/s", $fp, $arrMatch);
$strPNameTmp = $arrMatch[1];
preg_match("/<!-- @ Param Start @ \/\/-->(.+)<!-- @ Param End @ \/\/-->/s", $fp, $arrMatch);
$strParamTmp = $arrMatch[1];
preg_match("/<!-- @ BTParam Start @ \/\/-->(.+)<!-- @ BTParam End @ \/\/-->/s", $strParamTmp, $arrMatch);
$strBTParamTmp = $arrMatch[1];

//參數名稱
$strCon = "";
$intColspan = 0;

foreach($arrBP[$intFirstBT][0] as $strPName => $strPValue){
	if($arrPower[1] != "all" && ($strPName == "preOdds" || $strPName == "isAutoSupple" || $strPName == "AutoSuppleOverGold"))continue;
	if($isRealPayOffJumpWager == 0){
		if($strPName == "PayOffJump" || $strPName == "PayOffJumpRate")continue;
	}
	if($objLotto -> LType != 3 && $strPName == "StakeJump1")continue;

	$strTmp = $strPNameTmp;
	$strTmp = str_replace("{ShowPName}", $_strLotto[$strPName], $strTmp);
	$strCon .= $strTmp;
	$intColspan++;
}
$fp = preg_replace("/<!-- @ PName Start @ \/\/-->.+<!-- @ PName End @ \/\/-->/s", $strCon, $fp);
//exit($fp);



//參數內容
$strCon = "";
//$intColspan = 1+ sizeof($arrBP[$intFirstBT]);
//if(!$arrPower[1] != "all")$intColspan -= 1;
foreach($_arrBTOrder[$objLotto -> LType] as $intBT){
	$strSubCon = "";

	$arrApointNumTip = $_arrGLineApointNumTip[$objLotto -> ID][$intBT];
	if(!is_array($arrApointNumTip))$arrApointNumTip = array("");
	foreach($arrApointNumTip as $intApointNum => $strApointTip){
		$strTriCon = "";
		$strTmp = $strParamTmp;
		$strTmp = str_replace("{ShowBTName}", $arrBT[$intBT], $strTmp);
		$strTmp = str_replace("{ShowApoint}", $strApointTip, $strTmp);

		foreach($arrBP[$intFirstBT][0] as $strPName => $strPValue){
			$strPValue = $arrBP[$intBT][$intApointNum][$strPName];

			if($arrPower[1] != "all" && ($strPName == "preOdds" || $strPName == "isAutoSupple" || $strPName == "AutoSuppleOverGold")){
				$strSubTmp = "<input type='hidden' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='".$strPValue."'>";
				$strSubTmp .= "<input type='hidden' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='".$strPValue."'>";
				$strSubTmp .= "<input type='hidden' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='".$strPValue."'>";
			}else{
				if($isRealPayOffJumpWager == 0){
					if($strPName == "PayOffJump" || $strPName == "PayOffJumpRate")continue;
				}
				if($objLotto -> LType != 3 && $strPName == "StakeJump1")continue;

				$strSubTmp = $strBTParamTmp;
				if($strPName == "PayOffJump" || $strPName == "PayOffJumpRate"){
					$strSubTmp = str_replace("{ParamClass}", "PayOffJump", $strSubTmp);
				}

				$strOnKeyUp = "";
				if($objLotto -> LType == 1 && $intBT == 1 && $strPName == "preOdds"){
					$strOnKeyUp = 'onkeyup="setBT1();"';
				}elseif($objLotto -> LType == 1 && $intBT == 28 && $strPName == "preOdds"){
					$strOnKeyUp = 'onkeyup="setBT28();"';
				}
				$intInputSize = ($strPName == "preOdds")?"20":"7";

				if((($objLotto -> LType == 1 && $intBT == 15) || ($objLotto -> LType == 4 && $intBT == 14)) && $strPName == "StakeJump"){
					$strInput = "<input type='zatexted' size='".$intInputSize."' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='0' class='input_text' ".$strOnKeyUp." disabled>&nbsp;";
				}elseif($strPName == "isAutoSupple"){
					//$strInput = "<input type='checkbox' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='1' class='input_text' ".($strPValue == 1?"checked":"").">&nbsp;";
					$strInput = "<input type='radio' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='1' class='input_text' ".($strPValue == 1?"checked":"").">Y&nbsp;";
					$strInput .= "<input type='radio' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='0' class='input_text' ".($strPValue == 0?"checked":"").">N&nbsp;";
				}else{
					$strInput = "<input type='zatexted' size='".$intInputSize."' name='arrBetParam[".$intBT."][".$intApointNum."][".$strPName."]' value='".$strPValue."' class='input_text' ".$strOnKeyUp.">&nbsp;";
				}
				$strSubTmp = str_replace("{ShowBTParam}", $strInput, $strSubTmp);
			} //if($arrPower[1] != "all" && $strPName == "preOdds")
			$strTriCon .= $strSubTmp;
		} //foreach($arrBP[$intBT] as $strPName => $strPValue)
		$strSubCon .= preg_replace("/<!-- @ BTParam Start @ \/\/-->.+<!-- @ BTParam End @ \/\/-->/s", $strTriCon, $strTmp);

	} //foreach($arrApointNumTip as $intApointNum => $strApointTip){
	//exit($strSubCon);
	$strCon .= $strSubCon;
} //foreach($_arrBTOrder[$objLotto -> LType] as $intBT)
$fp = preg_replace("/<!-- @ Param Start @ \/\/-->.+<!-- @ Param End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>